package org.simple.learning.spring.boot.aop.aspect;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.*;
import org.simple.learning.spring.boot.aop.service.BService;
import org.simple.learning.spring.boot.aop.service.impl.BServiceImpl;
import org.springframework.stereotype.Component;

/**
 * 项目名称：spring-boot-leaning
 * 类名称：ServiceAspect
 * 类描述：ServiceAspect
 * 创建时间：2018/12/6
 *
 * @author guihuo   (E-mail:1620657419@qq.com)
 * @version v1.0
 */
@Aspect
@Component
public class ServiceAspect {

    @DeclareParents(value = "org.simple.learning.spring.boot.aop.service.AService+", defaultImpl = BServiceImpl.class)
    public BService bService;

    @Pointcut("execution(public * org.simple.learning.spring.boot.aop.service..*.*(..))")
    public void webLog() {
    }

    @Before("webLog()")
    public void before(JoinPoint joinPoint) throws Throwable {
        System.out.println("beforeJoinPoint");
    }

    @AfterReturning(pointcut = "webLog()")
    public void after(JoinPoint joinPoint) throws Throwable {
        System.out.println("afterJoinPoint");
    }


}
